POV-Ray : Newsgroups : povray.newusers : trace function question : Re: trace function question Server Time
29 Jul 2024 02:26:39 EDT (-0400)
  Re: trace function question  
From: serfurj
Date: 18 Jan 2007 16:25:00
Message: <web.45afe5111c5723b3e73422500@news.povray.org>
"Chris B" <c_b### [at] btconnectcomnospam> wrote:
>
> If you want a uniform distribution you probably want   #declare Start =
> vrotate ( <0,0,-2>, <asind(rand(R1)*2-1),rand(R1)*360,0> );
> This compensates by adjusting the distribution of the random numbers used
> for the x rotation, providing more points in the middle (xRotation=0) and
> less as you reach the extremes (xRotation=90 and xRotation= -90). It does
> this by taking the arcsin of a random number between -1 and 1.
>

Thank you for the thorough explanation!  You were correct, I meant uniformly
distributed, not evenly spaced.

I understand your approach, but it seems to only apply to placing objects on
a sphere.  Is there a way to place the cylinders uniformly on the
sphere_sweep or cylinder shapes below?  Is it possible to create a random
distribution of points in a space within a sphere_sweep or cylinder?


#include "colors.inc"
#include "debug.inc"
#include "math.inc"

camera {
      angle 20
      location<0,0,-50>
      look_at<0,0,0>
}

light_source { <0, 15, 10> color White }

background { White }

#declare MySphere =   sphere_sweep {
      linear_spline
      4,
      <-5, -5, 0>, 1
      <-5,  5, 0>, 1
      < 5, -5, 0>, 1
      < 5,  5, 0>, 1 }
//#declare MySphere = cylinder { <-1, -3, -1>, <1, 3, 1> 0.5 }

object {
  MySphere
  texture {
    pigment { rgb 1}
  }
}

#declare R1 = seed(33);
#declare Cnt = 0;

#while (Cnt<500)
  #declare Norm = <0, 0, 0>;
  #declare Start = vrotate (<0,0,-2>, <asind(rand(R1)*2-1),rand(R1)*360,0>);
  #declare Inter = trace ( MySphere, Start, <0, 0, 0>-Start, Norm );

  #debug concat(vstr(3,Start,",",3,3)"n")

  #if (vlength(Norm)!=0)
    cylinder {
      Inter, Inter+Norm, .1
      texture {
        pigment {color red 1}
      }
    }
  #end

  #declare Cnt = Cnt+1;
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.